package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/**
 * @Description
 * 发票种类：p,普通发票(电票)(默认);c,普通发票(纸票);s,专用发票;e,收购发票(电票);f,收购发票(纸质);r,普通发票(卷式);
 * b,增值税电子专用发票;j,机动车销售统一发票;u,二手车销售统一发票;
 * bs:电子发票(增值税专用发票)-即数电专票(电子),pc:电子发票(普通发票)-即数电普票(电子),
 * es:数电纸质发票(增值税专用发票)-即数电专票(纸质);ec:数电纸质发票(普通发票)-即数电普票(纸质)
 * es:数电纸质发票(增值税专用发票)-即数电专票(纸质);ec:数电纸质发票(普通发票)-即数电普票(纸质)
 * @Author Alan
 * @Date 2025/03/07
 */
public enum InvoiceLineEnum {

    PC("pc", "电子发票(普通发票)-即数电普票(电子)"),
    BS("bs", "电子发票(增值税专用发票)-即数电专票(电子)"),

    ;

    /**
     * 发票种类编号
     */
    private String invoiceLineCode;
    /**
     * 发票种类名称
     */
    private String invoiceLineName;

    InvoiceLineEnum(String invoiceLineCode, String invoiceLineName) {
        this.invoiceLineCode = invoiceLineCode;
        this.invoiceLineName = invoiceLineName;
    }

    public String getInvoiceLineCode() {
        return invoiceLineCode;
    }

    public String getInvoiceLineName() {
        return invoiceLineName;
    }

    public static InvoiceLineEnum resolve(String invoiceLineCode) {
        return Arrays.stream(values()).filter(o -> o.getInvoiceLineCode().equals(invoiceLineCode)).findFirst().orElseThrow(() -> new RuntimeException("查无此发票种类编码[" + invoiceLineCode + "]记录"));
    }


    @Override
    public String toString() {
        return String.format("%s:%s", invoiceLineCode, invoiceLineName);
    }
}
